/**
 * @author rxliuli
 */
const app = (() => {
    const {
        wait,
    } = rx
    return new Vue({
        el: '#app',
        data: {
            form: new BaseOperCompany(),
            officerList: [],
        },
        methods: {
            /**
             * 更新经营单位信息
             */
            async update() {
                this.$validator.validateAll().then(async (res) => {
                    if (res) {
                        if ( await ajaxOption({
                            res: baseOperCompanyApi.update({
                                ...this.form,
                                updateTime: new Date().toISOString(),
                                delFlag: 0,
                            }),
                            danger: '更新失败',
                            success: '更新成功，即将返回列表页面',
                        })) {
                            await wait(1000)
                            forward('/basic-data/admin_idc_info')
                        }
                    } else {
                        rxPrompt.dangerMsg("输入存在错误！");
                    }
                })
            },
        },
        computed: {},
        async mounted() {
            this.form = forward.getData()
            if(!this.form.securityOwner){
                this.form.securityOwner = ''
            }
            if(!this.form.emergencyContact){
                this.form.emergencyContact = ''
            }
            this.officerList = await baseHouseOfficerApi.selectList()
        },
    })
})()